﻿// JScript 文件

var pushName=new Array();
var pushSrc=new Array();
var pushLink=new Array();
var pushShow="";
var rollId;
var mainPushNum;
function $(id)
{
  return document.getElementById(id);
} 
function ShowIndexSildAd()
{             
     var IndexPicWindowObj=document.getElementById("IndexPicWindow");

     for(var i=0;i<IndexPicWindowObj.childNodes.length;i++)
     {
          if(IndexPicWindowObj.childNodes[i].hasChildNodes())
          {                   
            pushLink.push(IndexPicWindowObj.childNodes[i].getAttribute("href"));
            pushSrc.push(IndexPicWindowObj.childNodes[i].childNodes[0].getAttribute("src"));
            pushName.push(IndexPicWindowObj.childNodes[i].childNodes[1].nodeValue);
          }
     }             
    
    //初始化
    for(i=0;i<5;i++){
        pushShow+='<a href="'+pushLink[i]+'" onmouseover="showPushLink('+i+');clearInterval(rollId)" id="linkPush'+i+'" target="_blank">'+pushName[i]+'</a>';
    }
    document.getElementById("linkPush").innerHTML=pushShow;
    mainPushNum=rand(5);
    document.getElementById("linkPush"+mainPushNum).className="linkPushHere";
    document.getElementById("mainPush").innerHTML='<a href="'+pushLink[mainPushNum]+'" target="_blank" id="pushImgLink" onmouseover="clearInterval(rollId)" onmouseout="showAtTime()"><img src="'+pushSrc[mainPushNum]+'" name="pushImg" width="293" height="280" id="pushImg" alt="'+pushName[mainPushNum]+'" /></a>';
    rollId=setInterval("showPushLink()",5000);
} 

function nextSale(order){
	if(order=="up")	saleNum++;
	else saleNum--;
	if(saleNum>2)	saleNum=0
	else if(saleNum<0) saleNum=2;
	for(i=0;i<2;i++)
		document.getElementById("saleList"+i).style.display="none";
	document.getElementById("saleList"+saleNum).style.display="";
}
function showLink(name,order){
	for(i=0;i<2;i++){
		document.getElementById(name+"Push"+i).style.display="none";
		document.getElementById(name+"Link"+i).className=""
	}
	document.getElementById(name+"Push"+order).style.display="";
	document.getElementById(name+"Link"+order).className=name+"LinkHere";
}
function showPushLink(num){
	if(!num&&num!=0){
		mainPushNum++;
		if(mainPushNum>4) mainPushNum=0;
		num=mainPushNum;
	}
	for(i=0;i<5;i++){
		document.getElementById("linkPush"+i).className="";
	}
	document.getElementById("linkPush"+num).className="linkPushHere";
	document.getElementById("pushImg").src=pushSrc[num];
	document.getElementById("pushImgLink").href=pushLink[num];
	document.getElementById("pushImg").alt=pushName[num];
}
function showAtTime(){
	showPushLink();
	rollId=setInterval("showPushLink()",5000);
}
 function cleanWhiteSpace(element){
     for(var i=0;i<element.childNodes.lenght;i++){
        var node=element.childNodes[i];
        if(node.nodeType==3&&!/\S/.test(node.nodeValue))
        node.parentNode.removeChild(node);
     }
  
}
rnd.today=new Date(); 
rnd.seed=rnd.today.getTime(); 
function rnd(){ 
   rnd.seed = (rnd.seed*9301+49297) % 233280; 
  return rnd.seed/(233280.0); 
}

function rand(number){ 
   return Math.ceil(rnd()*number)-1; 
}  


function CheckLoginStatus(path) 
{  
    var LoginUserName=getCookie("Howave_UserName");
    var LoginPassword=getCookie("Howave_UserPassword");   
    
    
    if(LoginUserName!="" && LoginUserName!=null && LoginPassword!=null && LoginPassword!="")
    {  
        ShowTopLoginUserName(LoginUserName,path);
    }
    else
    {      
       ShowLogin(path);
    }
}  
function getCookie(cookieName)
{
    var cookieString = document.cookie
    var first ,last
    first=cookieString.indexOf(cookieName)
    if(first!=-1)
    {
       first+=(cookieName.length+1)
       last=cookieString.indexOf(';',first)
       return unescape(cookieString.substring(first,last));
    }
    return null;
}
function getCookies(cookieName)
{
    var cookieString = document.cookie
    var first ,last
    first=cookieString.indexOf(cookieName)
    if(first!=-1)
    {
       first+=(cookieName.length+1)
       last=cookieString.indexOf('&',first)
       return unescape(cookieString.substring(first,last));
    }
    return null;
}
function getCookieNum(cookieName)
{
    var cookieString = document.cookie
    var first ,last
    first=cookieString.indexOf(cookieName)
    if(first!=-1)
    {
       first+=(cookieName.length+1)
       //last=cookieString.indexOf('&',first)
       return unescape(cookieString.substring(first,cookieString.length));
    }
    return null;
}  

function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值 
{ 
var Days = 30; //此 cookie 将被保存 30 天 
var exp = new Date(); //new Date("December 31, 9998"); 
exp.setTime(exp.getTime() + Days*24*60*60*1000); 
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function delCookie(name)//删除cookie 
{ 
var exp = new Date(); 
exp.setTime(exp.getTime() - 1); 
var cval=getCookie(name); 
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
} 

function ShowTopLoginUserName(UserName,path)
{
 
  var welcomeObj=$("IndexTop1_welcome");
  var Howave_school=getCookie("Howave_school");
    if(Howave_school==null){
        Howave_school="";
    }

  if(welcomeObj!=null)
  {
     welcomeObj.innerHTML="<font color='#000'>您好，欢迎&nbsp;</font><span style='color:red'>"+UserName+""+Howave_school+"</span>！&nbsp;&nbsp;<a href='"+path+"Passport/Logout.aspx'>[退出]</a>";
     $("IndexTop1_login_status").style.display = "none";
     $("IndexTop1_regLink").style.display = "none";
     
  }  
}  
function ShowTopLoginSuccess()
{
  var UserName=getCookie("Howave_UnicodeUserName");
  var Howave_school=getCookie("Howave_school");
if(Howave_school==null){
Howave_school="";
}
  var welcomeObj=$("IndexTop1_welcome");
  if(welcomeObj!=null)
  {
     welcomeObj.innerHTML="<font color='#000'>您好，欢迎&nbsp;</font><span style='color:red'>"+UserName+""+Howave_school+"</span>！&nbsp;&nbsp;";
     
  }  
  var msgObj=$("IndexTop1_SiteMessage");
  if(msgObj)
  {
     GetUnReadMessage(escape(UserName),"UnReadMsgCount")
    
     
  }
  var msgIcon=$("MsgIcon");
  if(msgIcon!=null)
  {
    msgIcon.style.display="";
  }
  var LoginStatusObj=$("IndexTop1_login_status");
  var RegStatusObj=$("IndexTop1_regLink");
  var LoginUrl=LoginStatusObj.getAttribute("href");
  var LogoutUrl=LoginUrl.replace("Login","Logout");
  if(LoginStatusObj!=null)
  {
     LoginStatusObj.setAttribute("href",LogoutUrl);
     LoginStatusObj.innerHTML="[退出]";
    
  }  
  if(RegStatusObj!=null)
  {
       RegStatusObj.style.display="none";
  } 
   setTimeout("CheckLoginStatus()",60000);  //60秒更新一次顶部  
  
}

function ShowLogin()
{
  //$("IndexTop1_welcome").innerHTML="<font color='#000'>您好，欢迎！</font>&nbsp;&nbsp;";
  var LoginStatusObj=$("IndexTop1_login_status");
  var LoginUrl=LoginStatusObj.getAttribute("href");
  var LogoutUrl=LoginUrl.replace("Logout","Login");
  LoginStatusObj.setAttribute("href",LogoutUrl);
  LoginStatusObj.innerHTML="[登录]";
}  

         